package cate.common.table.activity.brightmythequipment.sheet;

import cate.common.table.ESheet;
import cate.common.table.activity.brightmythequipment.row.BrightMythDetailRow;

public class BrightMythDetailSheet extends ESheet<BrightMythDetailRow> {
    @Override
    public String getSheetName() {
        return "明细配置";
    }

//    private Map<Integer, Map<Integer, RWList<BrightMythDetailRow>>> groupMap;

    public BrightMythDetailRow getRowByConfig(int tid, int configId) {
        for (BrightMythDetailRow row :
                list) {
            if (row.id == tid & row.configId == configId) {
                return row;
            }
        }
        return null;
    }

    @Override
    protected void onLoaded() {
        super.onLoaded();
//        groupMap = new HashMap<>();
//        for (BrightMythDetailRow row : this.getList()) {
//            Map<Integer, RWList<BrightMythDetailRow>> configMap = groupMap.computeIfAbsent(row.grid, k -> new HashMap<>());
//            RWList<BrightMythDetailRow> rwList = configMap.get(row.configId);
//            if (rwList == null) {
//                rwList = new RWList<>();
//                configMap.put(row.configId, rwList);
//            }
//            rwList.add(row);
//        }
//        groupMap.values().forEach(item -> item.values().forEach(RWList::setup));
    }

//    public BrightMythDetailRow getRandom(int pos, int configId) {
//        BrightMythDetailRow row;
//        row = groupMap.get(pos).get(configId).get();
//        return row;
//    }

    public BrightMythDetailRow getRow(int pos,int configId) {
        for (BrightMythDetailRow row :
                getList()) {
            if (row.grid == pos && row.configId == configId) {
                return row;
            }
        }
        return null;
    }
}
